package cn.lin.dao;

import cn.lin.domain.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.annotations.HighlightParameters;
import org.springframework.data.elasticsearch.core.SearchPage;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRepository extends ElasticsearchRepository<User, Integer> {

    List<User> findByUsername(String username);

    //@Highlight:高亮显示
    @Highlight(fields = {
            @HighlightField(name = "title")},
            parameters =
            @HighlightParameters(preTags = "<strong><font style='color:red'>", postTags = "</font></strong>", fragmentSize = 500, numberOfFragments = 3)
    )
    SearchPage<User> findByUsernameOrderByIdAsc(String title,Pageable pageable);

//    @Highlight(fields = {
//            @HighlightField(name = "title")},
//            parameters =
//            @HighlightParameters(preTags = "<strong><font style='color:red'>", postTags = "</font></strong>", fragmentSize = 500, numberOfFragments = 3)
//    )
//    SearchPage<Article> findByTitleLike(String title, Pageable pageable);
}
//高亮

